<template>
  <view>
    <!-- 单商品banner -->
    <view class="list-item-center-two" v-if="orderitem.type == 'integral'">
      <view class="list-good-item">
        <image :src="orderitem.goods_pic" mode="aspectFill"></image>
        <view class="goods-info">
          <view class="goods-name">{{ orderitem.goods_name }}</view>
          <view class="goods-price integral-num">
            <text>{{ orderitem.cost | priceBeforeZero }}</text>
            <text>{{ orderitem.cost | priceAfterZero }}</text>
            <text class="">{{$t('shop.integral')}}</text>
          </view>
        </view>
      </view>
    </view>

    <view class="list-item-facePay" v-if="orderitem.type == 'scan'">
      <view class="list-good-item">
        <image :src="orderitem.goods_pic" mode="aspectFill"></image>
        <view class="goods-info">
          <view class="goods-name">{{$t('facePay.face')}}</view>
          <view class="goods-sku">{{
            orderitem.created_at | timestampToTime
          }}</view>
          <view class="goods-price">
            <text>￥</text>
            <text>{{ orderitem.pay_price | priceBeforeZero }}</text>
            <text>{{ orderitem.pay_price | priceAfterZero }}</text>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {};
  },
  props: {
    orderitem: {
      type: Object,
      default: {},
    },
  },
  filters: {
    priceBeforeZero(val) {
      if (val.indexOf(".") < 0) return `${val}.`;
      return val.substr(0, val.indexOf("."));
    },
    priceAfterZero(val) {
      if (val.indexOf(".") < 0) return "00";
      return val.substr(val.indexOf("."), val.lenhth);
    },
    timestampToTime(timestamp) {
      let date = new Date(timestamp * 1000); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
      let month = date.getMonth() + 1;
      let day = date.getDate();
      let y = date.getFullYear();
      let M = month ? "0" + month : month;
      let d = day < 10 ? "0" + day : day;
      let h = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
      let m =
        date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
      let s =
        date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
      return `${y}-${M}-${d} ${h}:${m}:${s}`;
    },
  },
  computed: {},
  mounted() {},
};
</script>

<style lang="scss" scoped>
.list-item-center-one {
  margin-top: 30rpx;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;

  scroll-view {
    overflow-x: scroll;
    flex: 1;
    white-space: nowrap;

    image {
      margin-right: 10rpx;
      width: 160rpx;
      height: 160rpx;
      border-radius: 10rpx;
      display: inline-block;
    }
    image:last-child {
      margin-right: 170rpx;
    }
  }

  .order-rightSide {
    width: 200rpx;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    right: 0;
    top: 0;
    z-index: 11;
    background: linear-gradient(
      90deg,
      rgba(255, 255, 255, 0),
      #ffffff,
      #ffffff
    );

    view:first-child {
      display: flex;
      flex-direction: column;
      text-align: right;
      width: 100%;

      .order-price {
        font-weight: bold;
        font-size: 34rpx;
        color: #262626;
        flex-direction: initial;
        align-items: baseline;
        justify-content: flex-end;

        text:first-child {
          font-size: 22rpx;
        }
        text:nth-child(2) {
          font-size: 34rpx;
        }
        text:last-child {
          font-size: 22rpx;
        }
      }
      view:last-child {
        margin-top: 4rpx;
        font-size: 24rpx;
        color: #8f8f8f;
      }
    }
  }
}
.list-item-center-two {
  margin-top: 30rpx;

  .list-good-item {
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;

    image {
      width: 160rpx;
      height: 160rpx;
      border-radius: 10rpx;
      margin-right: 24rpx;
    }

    .goods-info {
      flex: 1;
      max-width: 480rpx;

      .goods-name {
        font-size: 26rpx;
        font-family: PingFang SC;
        font-weight: 400;
        color: #262626;
        line-height: 32rpx;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
      }

      .goods-sku {
        font-size: 22rpx;
        font-family: PingFang SC;
        font-weight: 400;
        color: #8c8c8c;
        line-height: 26rpx;
        margin: 15rpx 0 17rpx 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }

      .goods-price {
        color: #262626;
        font-size: 22rpx;
        display: flex;
        align-items: baseline;
        text:nth-child(2) {
          font-size: 34rpx;
        }
      }

      .integral-num {
        text:nth-child(1) {
          font-size: 34rpx;
        }
        text:nth-child(2) {
          font-size: 22rpx;
        }
        text:last-child {
          margin-left: 5rpx;
        }
      }
    }
  }
}

.list-item-facePay {
  margin-top: 30rpx;
  .list-good-item {
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;

    image {
      width: 160rpx;
      height: 160rpx;
      border-radius: 10rpx;
      margin-right: 24rpx;
    }

    .goods-info {
      flex: 1;
      max-width: 480rpx;

      .goods-name {
        font-size: 26rpx;
        font-family: PingFang SC;
        font-weight: 400;
        color: #262626;
        line-height: 32rpx;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
      }

      .goods-sku {
        font-size: 22rpx;
        font-family: PingFang SC;
        font-weight: 400;
        color: #8c8c8c;
        line-height: 26rpx;
        margin: 15rpx 0 17rpx 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }

      .goods-price {
        color: #262626;
        font-size: 22rpx;
        display: flex;
        align-items: baseline;

        text:nth-child(1) {
          font-size: 22rpx;
        }
        text:nth-child(2) {
          font-size: 34rpx;
        }
        text:last-child {
          font-size: 22rpx;
        }
      }
    }
  }
}
</style>
